package com.example.threadpool.controller;

import com.example.threadpool.runnable.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadPoolExecutor;

@RestController
@RequestMapping("/threadPool")
public class ThreadPoolController {

    @Autowired
    private ThreadPoolExecutor threadPool;


    @GetMapping("/test")
    public String test() throws ExecutionException, InterruptedException {
        Test test = new Test();
        Future<String> submit = threadPool.submit(test);
        return "线程池的执行结果：" + submit.get();
    }



}
